package net.xju.controller;

import net.xju.common.framework.simplemvc.RequestMapping;
import net.xju.common.utils.JSONUtil;
import net.xju.common.utils.Result;
import net.xju.entity.User;
import net.xju.service.UserService;
import net.xju.service.impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RequestMapping("/user")
public class UserController {

    UserService userService = new UserServiceImpl();
    @RequestMapping("/login.do")
    public void login(HttpServletRequest req, HttpServletResponse resp){
        String name = req.getParameter("name");
        String password = req.getParameter("password");
        System.out.println(name + password);
    }

    @RequestMapping("/list.do")
    public void list(HttpServletRequest req , HttpServletResponse resp){

        List<User> userList = userService.list();
        JSONUtil.printByJSON(resp, Result.success(userList));
    }
}
